﻿@page "/wiki/{id:long}"
@attribute [Authorize]

@inject NavigationManager NavigationManager
@inject IWikiService WikiService

<MCard Class="mt-6" Style="padding: 8px;height:80vh">
    <MTabs Vertical>
        <MTab>
            <MIcon Left>
                mdi-database-outline
            </MIcon>
            数据列表
        </MTab>
        <MTab>
            <MIcon Left>
                mdi-radar
            </MIcon>
            搜索测试
        </MTab>
        <MTab>
            <MIcon Left>
                mdi-cog
            </MIcon>
            数据配置
        </MTab>

        <MTabItem>
            <MCard Flat>
                <MCardTitle>
                    <span>数据数量</span>
                    <MSpacer></MSpacer>
                    <MTextField Dense Outlined TValue="string" Label="搜索"></MTextField>
                    <MMenu OffsetY>
                        <ActivatorContent>
                            <MButton @attributes="@context.Attrs" Style="margin-bottom: 18px;margin-left: 8px;">
                                新增/导入
                            </MButton>
                        </ActivatorContent>
                        <ChildContent>
                            <MList Nav Dense>
                                <WikiUploadLocalFile OnSucceed="OnSucceed" Value="Id" />
                                <WikiUploadWebPage Value="Id" />
                                <MListItem Link>
                                    <MListItemIcon>
                                        <MIcon>mdi-text-box-edit-outline</MIcon>
                                    </MListItemIcon>

                                    <MListItemContent>
                                        <MListItemTitle>自定义文本</MListItemTitle>
                                    </MListItemContent>
                                </MListItem>
                            </MList>
                        </ChildContent>
                    </MMenu>
                </MCardTitle>
                <MCardText>
                    <MDataTable Headers="_headers"
                                Items="_wikiDetails.Result"
                                HideDefaultFooter="true"
                                Style="width:100%;">
                        <ItemColContent>
                            @if (context.Header.Value == nameof(WikiDetailDto.Id))
                            {
                                <span>@_wikiDetails.Result.IndexOf(context.Item)</span>
                            }
                            else if (context.Header.Value == nameof(WikiDetailDto.FileName))
                            {
                                <span>@context.Value</span>
                            }
                            else if (context.Header.Value == nameof(WikiDetailDto.DataCount))
                            {
                                <span>@context.Value</span>
                            }
                            else if (context.Header.Value == nameof(WikiDetailDto.Type))
                            {
                                <span>@context.Value</span>
                            }
                            else if (context.Header.Value == nameof(WikiDetailDto.CreationTime))
                            {
                                <span>@context.Value</span>
                            }
                            else if (context.Header.Value == nameof(WikiDetailDto.State))
                            {
                                <span>@context.Item.StateName</span>
                            }
                            else
                            {
                                <MButton OnClick="()=>OpenWikiDetailAsync(context.Item)">
                                    查看
                                </MButton>
                                <MMenu Left
                                       Bottom>
                                    <ActivatorContent Context="menu">
                                        <MButton Icon @attributes="@menu.Attrs">
                                            <MIcon>mdi-dots-vertical</MIcon>
                                        </MButton>
                                    </ActivatorContent>
                                    <ChildContent>
                                        <MList>
                                            <MListItem OnClick=" () =>  Remove(context.Item.Id)">
                                                <MListItemTitle>删除</MListItemTitle>
                                            </MListItem>
                                        </MList>
                                    </ChildContent>
                                </MMenu>
                            }
                        </ItemColContent>
                        <FooterContent>
                            <MPagination Value="page" ValueChanged="OnPageChanged" Class="my-4" Length=@((int)Math.Ceiling((double)_wikiDetails.Total / pageSize))></MPagination>
                        </FooterContent>
                    </MDataTable>

                </MCardText>
            </MCard>
        </MTabItem>
        <MTabItem>
            <MCard Flat Style="padding:8px;">
                <WikiSearchTest Value="Id"></WikiSearchTest>
            </MCard>
        </MTabItem>
        <MTabItem>
            <MCard Flat Style="padding:8px;">
                <WikiConfiguration Value="@Wiki" />
            </MCard>
        </MTabItem>
    </MTabs>
</MCard>

<style>
    .flex {
        display: flex;
    }

    .flex-1 {
        flex: 1;
    }

    .w-64 {
        width: 16rem;
        /* 黑色边框 */
        border: 1px solid #000;
        border-radius: 12px;
    }

    .mt-6 {
        margin-top: 1.5rem;
    }
</style>